home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 3 / Gold Medal Software - Volume 3 (Gold Medal) (1994).iso / prog / dnalib59.arj / DNAWRITE.BAS < prev    next >
BASIC Source File  |  1994-02-16  |  59KB  |  1,994 lines

  1. DECLARE SUB GetStrLoc() 'we have to declare this because we need it
  2. $INCLUDE "DNALIB.INC"
  3. $LINK "DNALIB.PBL"
  4.  
  5. StatusAttr% = 14: BarAttr% = 112: HelpTextColor% = 0
  6. HelpAttr% = 48: TextAttr% = 30: ErrorTxt% = 14: ErrorAttr% = 79
  7. Allow$ = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-=`~!@#$%^&*()_+}{[]:;'?><,./\|"
  8. SearchFor$ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-*~='└├╞╟╚╔╠╙╘╒╓┌"
  9. Delimiter$ = " ,($[{" + CHR$(10)
  10. Top% = 3: Bottom% = 23: LeftSide% = 2: RightSide% = 79: TextWidth% = 78
  11. Pointer% = 1: Offset% = 0: Immbed% = 0: Tag% = 0
  12.  
  13. IF MouseThere% THEN Mouse% = 1
  14.  
  15. DIM About$(15)
  16. DIM Prnter$(40)
  17. DIM Action$(40)
  18.  
  19. HorzMenu$(1) = "@File" :HorzMenu$(2) = "@Edit"
  20. HorzMenu$(3) = "@Search" :HorzMenu$(4) = "@Utilities"
  21. HorzMenu$(5) = "@Help"
  22.  
  23. VertMenu1$(1) = "@New" :VertMenu1$(2) = "@Open" :VertMenu1$(3) = "@Save"
  24. VertMenu1$(4) = "Save @As" :VertMenu1$(5) = "@Print" :VertMenu1$(6) = "@Dos Shell"
  25. VertMenu1$(7) = "E@xit"
  26.  
  27. VertMenu2$(1) = "Cu@t" :VertMenu2$(2) = "@Copy"
  28. VertMenu2$(3) = "@Paste" :VertMenu2$(4) = "@Delete"
  29. VertMenu2$(5) = "@Show Clipboard"
  30.  
  31. VertMenu3$(1) = "@Find" :VertMenu3$(2) = "@Replace"
  32. VertMenu3$(3) = "@Search again"
  33.  
  34. VertMenu4$(1) = "Printer @Setup": VertMenu4$(2) = "Codes to @Printer"
  35. VertMenu4$(3) = "@Tagging OFF"
  36.  
  37. VertMenu5$(1) = "@Help" :VertMenu5$(2) = "About @DNA.Write"
  38.  
  39. About$(1) = "DNA Library meets PBWrite"
  40. About$(2) = "by"
  41. About$(3) = " Chris Foot. Erik Olson. Lloyd Smith. Mel Bishop "
  42. About$(4) = " "
  43. About$(5) = "I would like to thank the above people and others "
  44. About$(6) = "who have contributed source code either knowingly "
  45. About$(7) = "or other wise to this project.   And to encourage "
  46. About$(8) = "other PowerBASIC users to share their Source code "
  47. About$(9) = " "
  48. About$(10) = "  I can be reached at the PowerBASIC tech support"
  49. About$(11) = "BBS or at this address                           "
  50. About$(12) = "                               15305 - 117 avenue"
  51. About$(13) = "                                Edmonton, Alberta"
  52. About$(14) = "FAX (403)452-5969                 CANADA, T5M 3X4"
  53.  
  54. ON ERROR GOTO WriteError
  55.  
  56. IF LEN(COMMAND$) THEN
  57.   FileName$ = COMMAND$
  58.   Test$ = DIR$(FileName$)
  59.   IF LEN(Test$) THEN
  60.     Been% = 1
  61.     GOSUB LoadFile
  62.   ELSE
  63.     IF YesNo%("File does not Exist! should I create it? (Y or N)",1,10,79,112,1,1) THEN
  64.       Been% = 1
  65.       GOSUB LoadFile
  66.     ELSE
  67.       Test$ = DIR$("NONAME.TXT")
  68.       IF LEN(Test$) THEN
  69.         FileName$ = "NONAME.TXT"
  70.         Been% = 1
  71.         GOSUB LoadFile
  72.       ELSE
  73.         GOSUB DefaultFile
  74.       END IF
  75.     END IF
  76.   END IF
  77. ELSE
  78.   Test$ = DIR$("NONAME.TXT")
  79.   IF LEN(Test$) THEN
  80.     FileName$ = "NONAME.TXT"
  81.     Been% = 1
  82.     GOSUB LoadFile
  83.   ELSE
  84.     GOSUB DefaultFile
  85.   END IF
  86. END IF
  87.  
  88. SplitPath GetProgramName$, Home$, EXEName$
  89.  
  90. SCREEN 0
  91.  
  92. TopRow% = 1
  93. Marker% = 99
  94. Popwind Title$,2,1,24,80,23,Shadow%,1
  95. COLOR 7,1
  96. LOCATE 24,3,0
  97. PRINT "┤Line:     Col:     ├────────┤FileSize:        ├"
  98. LOCATE 4,80,0: PRINT CHR$(24);
  99. LOCATE 22,80,0: PRINT CHR$(25);
  100. LOCATE 24,62,0: PRINT CHR$(27) + STRING$(16,176) + CHR$(26);
  101. AreaCLS 5,80,17,1,176,23
  102. COLOR 0,7
  103. LOCATE 25,1,0
  104. PRINT SPACE$(80);
  105. COLOR 4,7
  106. LOCATE 25,2,0: PRINT "F1       F2       F3       F4               F6";
  107. COLOR 0,7
  108. LOCATE 25,4,0: PRINT "-Help";
  109. LOCATE 25,13,0: PRINT "-Save";
  110. LOCATE 25,22,0: PRINT "-Open";
  111. LOCATE 25,31,0: PRINT "-Search Again";
  112. LOCATE 25,48,0: PRINT "-Load Macros";
  113.  
  114. Menu:
  115.  
  116. LockStatus 25,70,BarAttr%,StatusAttr%
  117.  
  118. HORIZONTALMENU HorzMenu$(),BarSave$,HiLight%,Mouse%,HPointer%,4,112,15,TopRow%,4,Marker%
  119.  
  120. SELECT CASE HPointer%
  121.     CASE 1  'Miscellaneous
  122.       VERTICALMENU VertMenu1$(),VertInfo1$(),VRtrn$,BarSave$,Mouse%,4,HelpTextColor%,HelpAttr%,15,TopRow%,Marker%,HPointer%,112,1,1
  123.       IF LEN(VRtrn$) THEN
  124.         SELECT CASE VRtrn$
  125.         CASE "New"
  126.                   GOSUB ClearAll
  127.                 CASE "Open"
  128.                   GOSUB LoadNew
  129.         CASE "Save"
  130.                   GOSUB Save
  131.                 CASE "Save As"
  132.                   GOSUB SaveAs
  133.                 CASE "Print"
  134.                   IF LEN(Block$) THEN
  135.                     IF YesNo%("Print Marked Text? (Y or N)",1,10,79,112,1,1) THEN
  136.                       WIDTH "LPT1:",255
  137.                       LPRINT Block$
  138.                     ELSE
  139.                       GOSUB PrintAll
  140.                     END IF
  141.                   ELSE
  142.                     GOSUB PrintAll
  143.                   END IF
  144.                 CASE "Dos Shell"
  145.                   GOSUB DosShell
  146.                 CASE "Exit"
  147.                   IF NoSave% THEN
  148.                     IF YesNo%("Quit and Lose Changes to Current File? (Y or N)",1,10,79,112,1,1) THEN
  149.                       GOTO WayOut
  150.                     ELSE
  151.                       GOSUB QuitSave
  152.                     END IF
  153.                   ELSE
  154.                     GOTO WayOut
  155.                   END IF
  156.         END SELECT
  157.           ELSE
  158.             IF Marker% THEN GOTO Menu
  159.       END IF
  160.     CASE 2  'Edit
  161.           VERTICALMENU VertMenu2$(),VertInfo2$(),VRtrn$,BarSave$,Mouse%,4,HelpTextColor%,HelpAttr%,15,TopRow%,Marker%,HPointer%,112,1,1
  162.       IF LEN(VRtrn$) THEN
  163.         SELECT CASE VRtrn$
  164.         CASE "Cut"
  165.                   GOSUB DeleteBlock
  166.         CASE "Copy"
  167.         CASE "Paste"
  168.                   GOSUB CopyBlock
  169.         CASE "Delete"
  170.         CASE "Show Clipboard"
  171.                   IF LEN(Block$) THEN
  172.                     GOSUB ViewClipboard
  173.                   ELSE
  174.                     Message$(1) = " Nothing to View "
  175.                     SOUND 50,5
  176.                     DIALOG Message$(),"",Mouse%,3,0,0,ErrorTxt%,ErrorAttr%,1,2
  177.                   END IF
  178.         END SELECT
  179.           ELSE
  180.             IF Marker% THEN GOTO Menu
  181.       END IF
  182.     CASE 3  'Screen
  183.           VERTICALMENU VertMenu3$(),VertInfo3$(),VRtrn$,BarSave$,Mouse%,4,HelpTextColor%,HelpAttr%,15,TopRow%,Marker%,HPointer%,112,1,1
  184.       IF LEN(VRtrn$) THEN
  185.         SELECT CASE VRtrn$
  186.         CASE "Find"
  187.                   GOSUB FindText
  188.                 CASE "Replace"
  189.                   GOSUB SearchAndReplace
  190.                 CASE "Search again"
  191.                   GOSUB SearchAgain
  192.         END SELECT
  193.           ELSE
  194.             IF Marker% THEN GOTO Menu
  195.       END IF
  196.     CASE 4  'Utilities
  197.           VERTICALMENU VertMenu4$(),VertInfo4$(),VRtrn$,BarSave$,Mouse%,4,HelpTextColor%,HelpAttr%,15,TopRow%,Marker%,HPointer%,112,1,1
  198.       IF LEN(VRtrn$) THEN
  199.         SELECT CASE VRtrn$
  200.         CASE "Printer Setup"
  201.                   GOSUB PrinterSetup
  202.                 CASE "Codes to Printer"
  203.                   VertMenu4$(2) = "Codes to @Document"
  204.                   Immbed% = 1
  205.                 CASE "Codes to Document"
  206.                   VertMenu4$(2) = "Codes to @Printer"
  207.                   Immbed% = 0
  208.                 CASE "Tagging ON"
  209.                   VertMenu4$(3) = "@Tagging OFF"
  210.                   Tag% = 0
  211.                 CASE "Tagging OFF"
  212.                   VertMenu4$(3) = "@Tagging ON"
  213.                   Tag% = 4
  214.         END SELECT
  215.           ELSE
  216.             IF Marker% THEN GOTO Menu
  217.       END IF
  218.     CASE 5  'Help
  219.           VERTICALMENU VertMenu5$(),VertInfo5$(),VRtrn$,BarSave$,Mouse%,4,HelpTextColor%,HelpAttr%,15,TopRow%,Marker%,HPointer%,112,1,1
  220.       IF LEN(VRtrn$) THEN
  221.         SELECT CASE VRtrn$
  222.         CASE "Help"
  223.                   GOSUB KeyBoardHelp
  224.         CASE "About DNA.Write"
  225.           DIALOG About$(),"",Mouse%,3,0,0,0,112,1,1
  226.         END SELECT
  227.           ELSE
  228.             IF Marker% THEN GOTO Menu
  229.       END IF
  230. END SELECT
  231.  
  232. IF Been% = 0 THEN
  233.   DIALOG About$(),"",Mouse%,3,0,0,0,112,1,1
  234.   Been% = 1
  235. END IF
  236.  
  237. DO
  238.  
  239. MouseJump:
  240.  
  241. GOSUB PrintRoutine
  242.  
  243. IF CursorRow% < 3 OR CursorRow% > 23 THEN CursorRow% = 3
  244. IF CursorCol% < 2 OR CursorCol% > 79 THEN CursorCol% = 2
  245.  
  246. GOSUB FileInfo
  247.  
  248. IF InsertKey% THEN
  249.   LOCATE CursorRow%,CursorCol%,1,0,13    'Block Cursor
  250. ELSE
  251.   LOCATE CursorRow%,CursorCol%,1,11,12   'Normal Cursor
  252. END IF
  253.  
  254. WHILE NOT INSTAT
  255.   IF Mouse% THEN
  256.     ShowCursor
  257.     Rgt% = 0:Lft% = 0
  258.     Clicked Rgt%,Lft%,MRow%,MCol%
  259.     IF MRow% >= Top% - 2 AND MRow% <= Bottom% + 2 AND MCol% >= LeftSide% - 1 AND MCol% <= RightSide% + 1 THEN
  260.       IF MRow% >= Top% AND MRow% <= Bottom% AND MCol% >= LeftSide% AND MCol% <= RightSide% THEN
  261.         IF Lft% THEN
  262.           CursorRow% = MRow%: CursorCol% = MCol%
  263.           LOCATE CursorRow%,CursorCol%,1
  264.           GOTO MouseJump
  265.         END IF
  266.       ELSE
  267.         SELECT CASE MRow%
  268.           CASE 1
  269.             IF LeftButtonReleased% THEN
  270.               FindMenu MRow%,MCol%,Found%
  271.               IF Found% THEN
  272.                 HPointer% = Found%: Marker% = 1: HiLight% = 1: GOTO Menu
  273.               END IF
  274.             END IF
  275.           CASE 2
  276.           CASE 4        'Scroll arrow up
  277.             IF Lft% AND MCol% = 80 THEN
  278.               Editkey% = 26: GOTO KeyBoardRoutine
  279.             END IF
  280.           CASE 5 TO 21  'pageing
  281.           CASE 22       'Scroll arrow down
  282.             IF Lft% AND MCol% = 80 THEN
  283.               Editkey% = 23: GOTO KeyBoardRoutine
  284.             END IF
  285.           CASE 24
  286.             SELECT CASE MCol%
  287.               CASE 62
  288.                 IF Lft% THEN
  289.                   Editkey% = -157: GOTO KeyBoardRoutine
  290.                 END IF
  291.               CASE 63 TO 78  'Home and End?
  292.               CASE 79
  293.                 IF Lft% THEN
  294.                   Editkey% = -155: GOTO KeyBoardRoutine
  295.                 END IF
  296.             END SELECT
  297.           CASE 25
  298.             IF LeftButtonReleased% THEN
  299.               ScreenPlus MRow%,MCol%,TextFound$
  300.               SELECT CASE TextFound$
  301.                 CASE "F1-Help"
  302.                   Editkey% = -59:GOTO KeyBoardRoutine
  303.                 CASE "F2-Save"
  304.                   Editkey% = -60:GOTO KeyBoardRoutine
  305.                 CASE "F3-Open"
  306.                   Editkey% = -61:GOTO KeyBoardRoutine
  307.                 CASE "F4-Search","Again"
  308.                   Editkey% = -62:GOTO KeyBoardRoutine
  309.                 CASE "F6-Load","Macros"
  310.                   Editkey% = -64:GOTO KeyBoardRoutine
  311.               END SELECT
  312.             END IF
  313.         END SELECT
  314.       END IF
  315.     END IF
  316.   END IF
  317.   IF KeyDown% THEN
  318.     LockStatus 25,70,BarAttr%,StatusAttr%
  319.     LOCATE CursorRow%,CursorCol%,1
  320.   END IF
  321.   IF AltKey% THEN HiLight% = 1: GOTO Menu
  322. WEND
  323.  
  324. Ky$ = INKEY$
  325.  
  326. IF LEN(Ky$) = 1 THEN
  327.   EditKey% = ASC(Ky$)
  328. ELSE
  329.   EditKey% = -ASC(RIGHT$(Ky$,1))
  330. END IF
  331.  
  332. KeyBoardRoutine:
  333.  
  334. SELECT CASE EditKey%
  335.         CASE 1     'Ctrl A
  336.           GOSUB WordLeft
  337.         CASE 3     'Ctrl C
  338.           GOSUB PageDown
  339.         CASE 4     'Ctrl D
  340.           GOSUB MoveRight
  341.         CASE 5     'Ctrl E
  342.           GOSUB MoveUp
  343.         CASE 6     'Ctrl F
  344.           GOSUB WordRight
  345.         CASE 7     'Ctrl G
  346.           GOSUB DeleteKey
  347.     CASE 8     'BackSpace or Ctrl H
  348.           GOSUB BackSpace
  349.         CASE 9     'TabKey
  350.           GOSUB TabKey
  351.         CASE 11    'Ctrl K
  352.           GOSUB CtrlKHelp
  353.           WHILE NOT INSTAT
  354.             IF Mouse% THEN
  355.               ShowCursor
  356.               Rgt% = 0:Lft% = 0
  357.               Clicked Rgt%,Lft%,MRow%,MCol%
  358.               IF Lft% THEN
  359.                 CtrlKKey% = 0: GOTO CtrlKRoutine
  360.               END IF
  361.             END IF
  362.           WEND
  363.  
  364.           Ky$ = INKEY$
  365.  
  366.           IF LEN(Ky$) = 1 THEN
  367.             CtrlKKey% = ASC(Ky$)
  368.           ELSE
  369.             CtrlKKey% = -ASC(RIGHT$(Ky$,1))
  370.           END IF
  371.  
  372.           CtrlKRoutine:
  373.           RestoreScreen CtrlK$,6,50
  374.           SELECT CASE CtrlKKey%
  375.                  CASE 2,66,98   '^K B Mark Block begin
  376.                    GOSUB MarkBlockBegin
  377.                  CASE 3,67,99   '^K C Copy Block
  378.                    GOSUB CopyBlock
  379.                  CASE 4,68,100  '^K D Save and Exit
  380.                    GOSUB QuitSave
  381.                  CASE 8,72,104  '^K H View Clipboard
  382.                    IF LEN(Block$) THEN
  383.                      GOSUB ViewClipboard
  384.                    ELSE
  385.                      Message$(1) = " Nothing to View "
  386.                      SOUND 50,5
  387.                      DIALOG Message$(),"",Mouse%,3,0,0,ErrorTxt%,ErrorAttr%,1,2
  388.                    END IF
  389.                  CASE 11,75,107  '^K K Mark Block end
  390.                    GOSUB MarkBlockEnd
  391.                  CASE 14,78,110  '^K N Mark Position
  392.                    GOSUB MarkPosition
  393.                  CASE 16,80,112  '^K P Print Block
  394.                    IF LEN(Block$) THEN
  395.                      IF YesNo%("Print Marked Text? (Y or N)",1,10,79,112,1,1) THEN
  396.                        WIDTH "LPT1:",255
  397.                        LPRINT Block$
  398.                      ELSE
  399.                        GOSUB PrintAll
  400.                      END IF
  401.                ELSE
  402.                      GOSUB PrintAll
  403.                    END IF
  404.                  CASE 17,81,113  '^K Q Quit No Save
  405.                    IF NoSave% THEN
  406.                      IF YesNo%("Quit and Loose Changes to Current File? (Y or N)",1,10,79,112,1,1) THEN
  407.                        GOTO WayOut
  408.                      ELSE
  409.                        GOSUB QuitSave
  410.                      END IF
  411.                    ELSE
  412.                      GOTO WayOut
  413.                    END IF
  414.                  CASE 18,82,114  '^K R Read Block from disk
  415.                    InFile% = 1
  416.                    GOSUB InsertFile
  417.                  CASE 19,83,115  '^K S Save and Edit
  418.                    GOSUB Save
  419.                  CASE 20,84,116  '^K T Mark Single word
  420.                  CASE 22,86,118  '^K V Move Block
  421.                    GOSUB MoveBlock
  422.                  CASE 23,87,119  '^K W Write Block to disk
  423.                    IF LEN(Block$) THEN
  424.                      GOSUB WriteBlockToDisk
  425.                    ELSE
  426.                      Message$(1) = " Clipboard is Empty Nothing to Save "
  427.                      SOUND 50,5
  428.                      DIALOG Message$(),"",Mouse%,3,0,0,ErrorTxt%,ErrorAttr%,1,2
  429.                    END IF
  430.                  CASE 25,89,121  '^K Y Delete Block
  431.                    GOSUB DeleteBlock
  432.                  CASE -59     'F1 key
  433.                    GOSUB KeyBoardHelp
  434.           END SELECT
  435.         CASE 12    'Crtl L
  436.           GOSUB SearchAgain
  437.         CASE 13    'EnterKey
  438.           GOSUB CarriageReturn
  439.         CASE 14    'Ctrl N
  440.           GOSUB InsertLine
  441.         CASE 16    'Ctrl P
  442.           GOSUB ExtendedKeys
  443.         CASE 17    'Ctrl Q
  444.           GOSUB CtrlQHelp
  445.           WHILE NOT INSTAT
  446.             IF Mouse% THEN
  447.               ShowCursor
  448.               Rgt% = 0:Lft% = 0
  449.               Clicked Rgt%,Lft%,MRow%,MCol%
  450.               IF Lft% THEN
  451.                 CtrlQKey% = 0: GOTO CtrlQRoutine
  452.               END IF
  453.             END IF
  454.           WEND
  455.  
  456.           Ky$ = INKEY$
  457.  
  458.           IF LEN(Ky$) = 1 THEN
  459.             CtrlQKey% = ASC(Ky$)
  460.           ELSE
  461.             CtrlQKey% = -ASC(RIGHT$(Ky$,1))
  462.           END IF
  463.  
  464.           CtrlQRoutine:
  465.           RestoreScreen CtrlQ$,6,50
  466.           SELECT CASE CtrlQKey%
  467.  
  468.                  CASE 1,65,97   '^Q A Search and Replace
  469.                    GOSUB SearchAndReplace
  470.                  CASE 2,66,98   '^Q B Move to Block begin
  471.                    GOSUB RestoreBlockBegin
  472.                  CASE 3,67,99   '^Q C End of File
  473.                    GOSUB EndOfFile
  474.                  CASE 4,68,100  '^Q D End of line
  475.                    GOSUB LineEnd
  476.                  CASE 5,69,101  '^Q E Top of screen
  477.                    CursorRow% = Top%
  478.                  CASE 6,70,102  '^Q F Search
  479.                    GOSUB FindText
  480.                  CASE 11,75,107  '^Q K Move to Block end
  481.                    GOSUB RestoreBlockEnd
  482.                  CASE 12,76,108  '^Q L Restore line
  483.                    GOSUB RestoreLine
  484.                  CASE 16,80,112  '^Q P Move to previous position
  485.                    GOSUB RestorePosition
  486.                  CASE 18,82,114  '^Q R Start of File
  487.                    GOSUB StartOfFile
  488.                  CASE 19,83,115  '^Q S Start of line
  489.                    GOSUB LineStart
  490.                  CASE 23,87,119  '^Q W Last Message
  491.                    IF Message$(1) = "" THEN Message$(1) = "No Message to Restore"
  492.                    DIALOG Message$(),"",Mouse%,3,0,0,ErrorTxt%,ErrorAttr%,1,2
  493.                  CASE 24,88,120  '^Q X Bottom of screen
  494.                    CursorRow% = Bottom%
  495.                  CASE 25,89,121  '^Q Y Delete to end of line
  496.                    GOSUB DeleteToEndOfLine
  497.                  CASE -59     'F1 key
  498.                    GOSUB KeyBoardHelp
  499.           END SELECT
  500.         CASE 18    'Ctrl R
  501.           GOSUB PageUp
  502.         CASE 19    'Ctrl S
  503.           GOSUB MoveLeft
  504.         CASE 20    'Ctrl T
  505.           GOSUB DeleteWordRight
  506.         CASE 21    'Ctrl U
  507.           GOSUB RestoreLine
  508.         CASE 23    'Ctrl W
  509.           GOSUB ScrollUp
  510.         CASE 24    'Ctrl X
  511.           GOSUB MoveDown
  512.         CASE 25    'Ctrl Y
  513.           GOSUB DeleteLine
  514.         CASE 26    'Ctrl Z
  515.           GOSUB ScrollDown
  516.     CASE 27    'EscKey
  517.         CASE 32 TO 126 'Normal Editing Keys
  518.           GOSUB AddText
  519.         CASE -59   'F1 Key
  520.           GOSUB KeyBoardHelp
  521.         CASE -60   'F2 Key
  522.           GOSUB Save
  523.         CASE -61   'F3 Key
  524.           GOSUB LoadNew
  525.         CASE -62   'F4 Key
  526.           GOSUB SearchAgain
  527.         CASE -64   'F6 Key
  528.           GOSUB LoadMacro
  529.         CASE -65   'F7 Key
  530.           GOSUB PrinterSetup
  531.     CASE -71   'HomeKey
  532.           GOSUB LineStart
  533.         CASE -72   'Up Arrow
  534.           GOSUB MoveUp
  535.         CASE -73   'Page Up
  536.           GOSUB PageUp
  537.     CASE -75   'LeftArrow
  538.           GOSUB MoveLeft
  539.     CASE -77   'RightArrow
  540.           GOSUB MoveRight
  541.     CASE -79   'EndKey
  542.           GOSUB LineEnd
  543.         CASE -80   'Down Arrow
  544.           GOSUB MoveDown
  545.         CASE -81   'Page Down
  546.           GOSUB PageDown
  547.     CASE -82   'InsertKey
  548.           GOSUB ToggleInsert
  549.     CASE -83   'DeleteKey
  550.           GOSUB DeleteKey
  551.         CASE -94   'Ctrl F1
  552.           Mackro$ = Macro$(1)
  553.           GOSUB MacroKeys
  554.         CASE -95   'Ctrl F2
  555.           Mackro$ = Macro$(2)
  556.           GOSUB MacroKeys
  557.         CASE -96   'Ctrl F3
  558.           Mackro$ = Macro$(3)
  559.           GOSUB MacroKeys
  560.         CASE -97   'Ctrl F4
  561.           Mackro$ = Macro$(4)
  562.           GOSUB MacroKeys
  563.         CASE -98   'Ctrl F5
  564.           Mackro$ = Macro$(5)
  565.           GOSUB MacroKeys
  566.         CASE -99   'Ctrl F6
  567.           Mackro$ = Macro$(6)
  568.           GOSUB MacroKeys
  569.         CASE -100  'Ctrl F7
  570.           Mackro$ = Macro$(7)
  571.           GOSUB MacroKeys
  572.         CASE -101  'Ctrl F8
  573.           Mackro$ = Macro$(8)
  574.           GOSUB MacroKeys
  575.         CASE -102  'Ctrl F9
  576.           Mackro$ = Macro$(9)
  577.           GOSUB MacroKeys
  578.         CASE -103  'Ctrl F10
  579.           Mackro$ = Macro$(10)
  580.           GOSUB MacroKeys
  581.         CASE -115  'Ctrl LeftArrow
  582.           GOSUB WordLeft
  583.         CASE -116  'Ctrl RightArrow
  584.           GOSUB WordRight
  585.         CASE -117  'Ctrl End
  586.           CursorRow% = Bottom%
  587.         CASE -118  'Ctrl PgDn
  588.           GOSUB EndOfFile
  589.         CASE -119  'Ctrl Home
  590.           CursorRow% = Top%
  591.         CASE -132  'Ctrl PgUp
  592.           GOSUB StartOfFile
  593.         CASE -155
  594.           GOSUB ScrollLeft
  595.         CASE -157
  596.           GOSUB ScrollRight
  597.         CASE ELSE
  598.       BEEP
  599.  
  600. END SELECT
  601.  
  602. LOOP
  603.  
  604. WayOut:
  605.  
  606. DELAY .5
  607. COLOR 7,0
  608. CLS
  609.  
  610. END
  611. '----------------------------------------------------------------------------
  612. KeyBoardHelp:
  613.  
  614. BROWSE Home$ + "KEYBOARD.HLP",Mouse%,HelpTextColor%,3,12,23,67,HelpAttr%,1,1
  615.  
  616. RETURN
  617. '----------------------------------------------------------------------------
  618. MacroKeys:
  619.  
  620. NoSave% = 1
  621.  
  622. GOSUB CheckForChange
  623.  
  624. IF LEN(Mackro$) THEN
  625.   IF ((Offset% + CursorCol%) - LeftSide%) > EditLineLenght% THEN
  626.     Text$ = LEFT$(Text$,EditEndPointer% - 1) + _
  627.     SPACE$(((Offset% + CursorCol%) - LeftSide%) - EditLineLenght%) + _
  628.     Mackro$ + MID$(Text$, EditEndPointer%)
  629.   ELSE
  630.     Text$ = LEFT$(Text$,Character% - 1) + Mackro$ + MID$(Text$, Character%)
  631.   END IF
  632. END IF
  633.  
  634. RETURN
  635. '----------------------------------------------------------------------------
  636. LoadMacro:
  637.  
  638. MacroLoaded% = 0
  639. MacroName$(1) = "MACRO1.MAC": MacroName$(2) = "MACRO2.MAC"
  640. MacroName$(3) = "MACRO3.MAC": MacroName$(4) = "MACRO4.MAC"
  641. MacroName$(5) = "MACRO5.MAC": MacroName$(6) = "MACRO6.MAC"
  642. MacroName$(7) = "MACRO7.MAC": MacroName$(8) = "MACRO8.MAC"
  643. MacroName$(9) = "MACRO9.MAC": MacroName$(10) = "MACRO10.MAC"
  644.  
  645. FOR i% = 1 TO 10
  646.   Test$ = DIR$(Home$ + MacroName$(i%))
  647.   IF LEN(Test$) THEN
  648.     FileNumber% = FREEFILE
  649.     OPEN Home$ + MacroName$(i%) FOR BINARY AS FileNumber%
  650.       IF LOF(FileNumber%) < 2000 THEN
  651.         GET$ FileNumber%, LOF(FileNumber%), Macro$(i%)
  652.         MacroLoaded% = 1
  653.       END IF
  654.     CLOSE FileNumber%
  655.   END IF
  656. NEXT i%
  657.  
  658. IF MacroLoaded% THEN
  659.   COLOR 4,7: LOCATE 25,46,0: PRINT "Ctrl F1 to F10";
  660.   COLOR 0,7: LOCATE 25,60,0: PRINT "-Macro#";
  661. END IF
  662.  
  663. RETURN
  664. '----------------------------------------------------------------------------
  665. WordLeft:
  666.  
  667. Character% = EditStartPointer% + Offset% + (CursorCol% - LeftSide%)
  668. LeftWord% = Character%
  669.  
  670. IF EditStartPointer% THEN
  671.   DO
  672.     IF LeftWord% > 1 THEN
  673.       IF LeftWord% = EditStartPointer% AND LeftWord% > 1 THEN GOTO LineAbove
  674.       DECR LeftWord%
  675.     ELSE
  676.       Offset% = 0: CursorCol% = LeftSide%
  677.       EXIT
  678.     END IF
  679.     IF INSTR(MID$(Text$,LeftWord%,1),ANY SearchFor$) THEN
  680.       DO
  681.         IF LeftWord% > 1 THEN
  682.           DECR LeftWord%
  683.         ELSE
  684.           Offset% = 0: CursorCol% = LeftSide%
  685.           EXIT,EXIT
  686.         END IF
  687.         IF INSTR(MID$(Text$,LeftWord%,1),ANY DeLimiter$) THEN
  688.           DO
  689.           INCR LeftWord%
  690.             IF INSTR(MID$(Text$,LeftWord%,1),ANY SearchFor$) THEN
  691.               FOR l% = LeftWord% + 1 TO Character%
  692.                 GOSUB MoveLeft
  693.               NEXT l%
  694.               EXIT,EXIT,EXIT
  695.             END IF
  696.           LOOP UNTIL LeftWord% = Character%
  697.         END IF
  698.       LOOP
  699.     END IF
  700.   LOOP
  701. END IF
  702.  
  703. RETURN
  704. '----------------------------------------------------------------------------
  705. LineAbove:
  706.  
  707. GOSUB MoveUp
  708. GOSUB PrintRoutine
  709. GOSUB LineEnd
  710. GOTO WordLeft
  711.  
  712. '----------------------------------------------------------------------------
  713. WordRight:
  714.  
  715. Character% = EditStartPointer% + Offset% + (CursorCol% - LeftSide%)
  716. RightWord% = Character%
  717.  
  718. IF Character% < EditEndPointer% + 1 AND Character% < LEN(Text$) - 2 THEN
  719.   RightWord% = INSTR(RightWord%,Text$,ANY DeLimiter$)
  720.   IF RightWord% THEN
  721.     RightWord% = INSTR(RightWord%,Text$,ANY SearchFor$)
  722.     IF RightWord% < EditEndPointer% THEN
  723.       FOR i% = Character% TO RightWord% - 1
  724.         GOSUB MoveRight
  725.       NEXT i%
  726.     ELSE  'search for blank lines
  727.       BlankLine% = 0
  728.       FOR i% = EditEndPointer% + 1 TO RightWord%
  729.         IF MID$(Text$,i%,1) = CHR$(10) THEN
  730.           INCR BlankLine%
  731.           GOSUB MoveDown
  732.         END IF
  733.       NEXT i%
  734.       IF BlankLine% THEN
  735.         CursorCol% = ((RightWord% - EditEndPointer%) - (2 * BlankLine%)) + 2
  736.         IF CursorCol% > RightSide% THEN
  737.           Offset% = (CursorCol% - RightSide%) + LeftSide%
  738.           CursorCol% = RightSide% - 2
  739.         ELSE
  740.           Offset% = 0
  741.         END IF
  742.       ELSE
  743.         CursorCol% = RightWord% - EditEndPointer%
  744.         IF CursorCol% > RightSide% THEN
  745.           Offset% = (CursorCol% - RightSide%) + LeftSide%
  746.           CursorCol% = RightSide% - 2
  747.         ELSE
  748.           Offset% = 0
  749.         END IF
  750.         GOSUB MoveDown
  751.       END IF
  752.     END IF
  753.   END IF
  754. END IF
  755.  
  756. RETURN
  757. '----------------------------------------------------------------------------
  758. MarkWordRight:
  759.  
  760. RETURN
  761. '----------------------------------------------------------------------------
  762. AddText:
  763.  
  764. NoSave% = 1
  765.  
  766. GOSUB CheckForChange
  767.  
  768. IF Tabs% = 0 THEN
  769.   IF ((Offset% + CursorCol%) - LeftSide%) > EditLineLenght% THEN
  770.     Text$ = LEFT$(Text$,EditEndPointer% - 1) + _
  771.     SPACE$(((Offset% + CursorCol%) - LeftSide%) - EditLineLenght%) + _
  772.     MID$(Text$, EditEndPointer%)
  773.   END IF
  774. END IF
  775.  
  776. 'INSERT OR OVERTYPE THE CHARACTER
  777.  
  778. IF ISFALSE InsertKey% THEN
  779.   Text$ = LEFT$(Text$,Character% - 1) + Ky$ + MID$(Text$,Character%)
  780. ELSE
  781.   IF MID$(Text$,Character%,1) = CHR$(13) THEN
  782.     Text$ = LEFT$(Text$,Character% - 1) + Ky$ + MID$(Text$,Character%)
  783.   ELSE
  784.     MID$(Text$,Character%,1) = Ky$
  785.   END IF
  786. END IF
  787.  
  788. 'NOW ADJUST THE CURSOR POSITION
  789.  
  790. IF CursorCol% < 79 THEN
  791.   INCR CursorCol%
  792. ELSE
  793.   INCR Offset%
  794. END IF
  795.  
  796. RETURN
  797. '----------------------------------------------------------------------------
  798. ExtendedKeys:
  799.  
  800. Only$ = "1234567890"
  801. Num$ = "   "
  802. SAVESCREEN CtrlScreen$,3,4,22,76,1
  803. POPWIND "ASCII Table Quick Reference",3,4,17,76,112,1,1
  804. COLOR 0,7
  805. LOCATE 4,6,0: PRINT "001 " + CHR$(1) + "   004 " + CHR$(4) + "   007 " + CHR$(7) + "   014 " + CHR$(14) + "   017 " + CHR$(17) + "   020 " + CHR$(20) + "   023 " + CHR$(23) + "   026 " + CHR$(26) + "   029 " + CHR$(29);
  806. LOCATE 5,6,0: PRINT "002 " + CHR$(2) + "   005 " + CHR$(5) + "   011 " + CHR$(11) + "   015 " + CHR$(15) + "   018 " + CHR$(18) + "   021 " + CHR$(21) + "   024 " + CHR$(24) + "   027 " + CHR$(27) + "   030 " + CHR$(30);
  807. LOCATE 6,6,0: PRINT "003 " + CHR$(3) + "   006 " + CHR$(6) + "   012 " + CHR$(12) + "   016 " + CHR$(16) + "   019 " + CHR$(19) + "   022 " + CHR$(22) + "   025 " + CHR$(25) + "   028 " + CHR$(28) + "   031 " + CHR$(31);
  808. LOCATE 8,6,0: PRINT "174 «   183 ╖   192 └   201 ╔   210 ╥   219 █   228 Σ   237 φ   246 ÷";
  809. LOCATE 9,6,0: PRINT "175 »   184 ╕   193 ┴   202 ╩   211 ╙   220 ▄   229 σ   238 ε   247 ≈";
  810. LOCATE 10,6,0: PRINT "176 ░   185 ╣   194 ┬   203 ╦   212 ╘   221 ▌   230 µ   239 ∩   248 °";
  811. LOCATE 11,6,0: PRINT "177 ▒   186 ║   195 ├   204 ╠   213 ╒   222 ▐   231 τ   240 ≡   249 ∙";
  812. LOCATE 12,6,0: PRINT "178 ▓   187 ╗   196 ─   205 ═   214 ╓   223 ▀   232 Φ   241 ±   250 ·";
  813. LOCATE 13,6,0: PRINT "179 │   188 ╝   197 ┼   206 ╬   215 ╫   224 α   233 Θ   242 ≥   251 √";
  814. LOCATE 14,6,0: PRINT "180 ┤   189 ╜   198 ╞   207 ╧   216 ╪   225 ß   234 Ω   243 ≤   252 ⁿ";
  815. LOCATE 15,6,0: PRINT "181 ╡   190 ╛   199 ╟   208 ╨   217 ┘   226 Γ   235 δ   244 ⌠   253 ²";
  816. LOCATE 16,6,0: PRINT "182 ╢   191 ┐   200 ╚   209 ╤   218 ┌   227 π   236 ∞   245 ⌡   254 ■";
  817.  
  818. POPWIND Title$,20,55,22,76,112,1,1
  819. COLOR 0,7: LOCATE 21,57,0: PRINT "Extended Key #";
  820. LINEEDIT Only$,Num$,0,MouseRow%,MouseCol%,176,21,72,Editkey%,14
  821. RESTORESCREEN CtrlScreen$,3,4
  822. IF LEN(RTRIM$(Num$)) THEN
  823.   IF VAL(Num$) > 254 THEN
  824.     Message$(1) = " Sorry that Key is not supported "
  825.     SOUND 50,5
  826.     DIALOG Message$(),"",Mouse%,3,0,0,ErrorTxt%,ErrorAttr%,1,2
  827.   ELSE
  828.     Ky$ = CHR$(VAL(Num$))
  829.     IF INSTR(Ky$,ANY CHR$(9,10,13)) THEN
  830.       Message$(1) = " Sorry No Tabs, Linefeeds, or Carriage Returns "
  831.       SOUND 50,5
  832.       DIALOG Message$(),"",Mouse%,3,0,0,ErrorTxt%,ErrorAttr%,1,2
  833.     ELSE
  834.       GOSUB AddText
  835.     END IF
  836.   END IF
  837. END IF
  838.  
  839. RETURN
  840. '----------------------------------------------------------------------------
  841. InsertLine:
  842.  
  843. NoSave% = 1
  844.  
  845. GOSUB CheckForChange
  846.  
  847. o% = Offset%: c% = CursorCol%: r% = CursorRow%
  848. GOSUB CarriageReturn
  849. Offset% = o%: CursorCol% = c%: CursorRow% = r%
  850.  
  851. RETURN
  852. '----------------------------------------------------------------------------
  853. CarriageReturn:
  854.  
  855. NoSave% = 1
  856.  
  857. GOSUB CheckForChange
  858.  
  859. IF ((Offset% + CursorCol%) - LeftSide%) > EditLineLenght% THEN
  860.   Text$ = LEFT$(Text$,EditEndPointer% - 1) + CHR$(13) + CHR$(10) + _
  861.   MID$(Text$,EditEndPointer%)
  862. ELSE
  863.   Text$ = LEFT$(Text$,Character% - 1) + CHR$(13) + CHR$(10) + MID$(Text$,Character%)
  864. END IF
  865.  
  866. CursorCol% = LeftSide%
  867.  
  868. IF Offset% > 0 THEN Offset%=0
  869. IF CursorRow% < 23 THEN
  870.   INCR CursorRow%
  871. ELSE
  872.   IF TempPointer% < LEN(Text$) THEN
  873.     Pointer% = INSTR(Pointer%, Text$, CHR$(13)) + 2
  874.   END IF
  875. END IF
  876.  
  877. RETURN
  878. '----------------------------------------------------------------------------
  879. TabKey:
  880.  
  881. NoSave% = 1
  882.  
  883. GOSUB CheckForChange
  884.  
  885. IF ((Offset% + CursorCol%) - LeftSide%) > EditLineLenght% THEN
  886.   Tabs% = 8 - (((Offset% + CursorCol%) - LeftSide%) MOD 8)
  887.   Text$ = LEFT$(Text$,EditEndPointer% - 1) + _
  888.   SPACE$(((Offset% + CursorCol% + Tabs%) - LeftSide%) - EditLineLenght%) + _
  889.   MID$(Text$,EditEndPointer%)
  890.   GOSUB PrintRoutine
  891.   CursorCol% = (LeftSide% + EditLineLenght%) - Offset%
  892.   IF CursorCol% > 79 THEN GOSUB LineEnd
  893. ELSE
  894.   Tabs% = 8 - (((Offset% + CursorCol%) - LeftSide%) MOD 8)
  895.   FOR i% = 1 TO Tabs%
  896.     Ky$ = CHR$(32): GOSUB AddText
  897.   NEXT i%
  898. END IF
  899.  
  900. Tabs% = 0
  901.  
  902. RETURN
  903. '----------------------------------------------------------------------------
  904. DeleteKey:
  905.  
  906. NoSave% = 1
  907.  
  908. GOSUB CheckForChange
  909.  
  910. IF Character% =< EditEndPointer% THEN
  911.   IF LEN(Text$) THEN
  912.     IF MID$(Text$,Character%,1) = CHR$(13) THEN
  913.       Text$ = LEFT$(Text$,Character% - 1) + MID$(Text$,Character% + 2)
  914.     ELSE
  915.       Text$ = LEFT$(Text$,Character% - 1) + MID$(Text$,Character% + 1)
  916.     END IF
  917.   END IF
  918. END IF
  919.  
  920. RETURN
  921. '----------------------------------------------------------------------------
  922. ToggleInsert:
  923.  
  924. IF InsertKey% THEN
  925.   LOCATE ,,,0,13    'Block Cusor
  926. ELSE
  927.   LOCATE ,,,11,12   'Normal Cursor
  928. END IF
  929.  
  930. RETURN
  931. '----------------------------------------------------------------------------
  932. LineStart:
  933.  
  934. IF Offset% THEN
  935.   Offset% = 0
  936.   CursorCol% = LeftSide%
  937. ELSE
  938.   CursorCol% = LeftSide%
  939. END IF
  940.  
  941. RETURN
  942. '----------------------------------------------------------------------------
  943. LineEnd:
  944.  
  945. CursorCol% = LeftSide% + EditLineLenght%
  946.  
  947. IF CursorCol% > RightSide% THEN
  948.   CursorCol% = RightSide% - 1
  949.   Offset% = (EditLineLenght% - RightSide%) + (LeftSide% + 1)
  950. ELSE
  951.   Offset% = 0
  952. END IF
  953.  
  954. RETURN
  955. '----------------------------------------------------------------------------
  956. StartOfFile:
  957.  
  958. Pointer% = 1: Offset% = 0: CursorRow% = Top%: CursorCol% = LeftSide%
  959.  
  960. RETURN
  961. '----------------------------------------------------------------------------
  962. EndOfFile:
  963.  
  964. IF EditEndPointer% < LEN(Text$) - 2 THEN
  965.   Pointer% = LEN(Text$): Count% = 0: RowCount% = Top% - 1
  966.  
  967.   FOR PageLenght% = Top% TO Bottom%
  968.     IF Pointer% > 1 THEN
  969.       INCR RowCount%
  970.       DECR Pointer%,2
  971.       DO
  972.         DECR Pointer%
  973.         IF PageLenght% = Top% THEN INCR Count%
  974.       LOOP UNTIL MID$(Text$, Pointer%, 1) = CHR$(13) OR Pointer% = 1
  975.       IF Pointer% > 1 THEN INCR Pointer%,2
  976.     ELSE
  977.       EXIT FOR
  978.     END IF
  979.   NEXT PageLenght%
  980.  
  981.   IF Count% > 78 THEN
  982.     Offset% = Count% - 78: CursorCol% = RightSide%: CursorRow% = RowCount%
  983.   ELSE
  984.     Offset% = 0: CursorCol% = Count% + 1: CursorRow% = RowCount%
  985.   END IF
  986. ELSE
  987.   GOSUB LineEnd
  988. END IF
  989.  
  990. RETURN
  991. '----------------------------------------------------------------------------
  992. BackSpace:
  993.  
  994. NoSave% = 1
  995.  
  996. GOSUB CheckForChange
  997.  
  998. IF Offset% + (CursorCol% - LeftSide%) > EditLineLenght% THEN
  999.   Adjust% = 0
  1000. ELSE
  1001.   Adjust% = 1
  1002. END IF
  1003.  
  1004. IF Character% > 2 AND Offset% = 0 AND CursorCol% = LeftSide% THEN WrapUp% = 1
  1005.  
  1006. IF CursorCol% > 2 THEN
  1007.   DECR CursorCol%: DECR Character%: NormalLine% = 1
  1008. ELSE
  1009.   IF Offset% THEN DECR Offset%: DECR Character%: NormalLine% = 1
  1010. END IF
  1011.  
  1012. IF Adjust% THEN
  1013.   IF WrapUp% THEN
  1014.     Text$ = LEFT$(Text$,Character% - 3) + MID$(Text$,Character%)
  1015.     Ptr% = EditStartPointer%: Count% = 0: WrapUp% = 0:
  1016.  
  1017.     DECR Ptr%,2
  1018.     DO
  1019.       DECR Ptr%
  1020.       IF Ptr% = 0 THEN EXIT LOOP
  1021.       IF Mid$(Text$,Ptr%,1) = CHR$(13) OR Ptr% = 1 THEN
  1022.         INCR Count%
  1023.         EXIT LOOP
  1024.       ELSE
  1025.         INCR Count%
  1026.       END IF
  1027.     LOOP
  1028.  
  1029.     IF Ptr% = 1 AND CursorRow% = Top% + 1 THEN INCR Count%,2
  1030.  
  1031.     IF Count% > 78 THEN
  1032.       Offset% = Count% - 79: CursorCol% = RightSide%
  1033.     ELSE
  1034.       Offset% = 0: CursorCol% = Count%
  1035.     END IF
  1036.     IF CursorRow% > Top% + 2 THEN
  1037.       DECR CursorRow%
  1038.     ELSE
  1039.       IF Pointer% > 1 THEN
  1040.         GOSUB ScrollDown
  1041.       ELSE
  1042.         DECR CursorRow%
  1043.       END IF
  1044.     END IF
  1045.   ELSE
  1046.     IF NormalLine% THEN
  1047.       NormalLine% = 0
  1048.       IF LEN(Text$) AND MID$(Text$,Character%,1) <> CHR$(13) AND _
  1049.       MID$(Text$,Character%,1) <> CHR$(10) THEN_
  1050.       Text$ = LEFT$(Text$,Character% - 1) + MID$(Text$,Character% + 1)
  1051.     END IF
  1052.   END IF
  1053. END IF
  1054.  
  1055. RETURN
  1056. '----------------------------------------------------------------------------
  1057. ScrollRight:
  1058.  
  1059. IF Offset% THEN DECR Offset%
  1060.  
  1061. RETURN
  1062. '----------------------------------------------------------------------------
  1063. ScrollLeft:
  1064.  
  1065. INCR Offset%
  1066.  
  1067. RETURN
  1068. '----------------------------------------------------------------------------
  1069. MoveRight:
  1070.  
  1071.   IF CursorCol% < 79 THEN
  1072.     INCR CursorCol%
  1073.   ELSE
  1074.     INCR Offset%
  1075.   END IF
  1076.  
  1077. RETURN
  1078. '----------------------------------------------------------------------------
  1079. MoveLeft:
  1080.  
  1081. IF CursorCol% > 2 THEN
  1082.   DECR CursorCol%
  1083. ELSE
  1084.   IF Offset% THEN DECR Offset%
  1085. END IF
  1086.  
  1087. RETURN
  1088. '----------------------------------------------------------------------------
  1089. MoveUp:
  1090.  
  1091. IF CursorRow% > 3 THEN
  1092.   DECR CursorRow%
  1093. ELSE
  1094.   GOSUB ScrollDown
  1095. END IF
  1096.  
  1097. RETURN
  1098. '----------------------------------------------------------------------------
  1099. MoveDown:
  1100.  
  1101. IF CursorRow% < 23 THEN
  1102.   INCR CursorRow%
  1103. ELSE
  1104.   GOSUB ScrollUp
  1105. END IF
  1106.  
  1107. RETURN
  1108. '----------------------------------------------------------------------------
  1109. PageUp:
  1110.  
  1111. FOR PageLenght% = Top% TO (Bottom% - 1)
  1112.   IF Pointer% > 1 THEN
  1113.     GOSUB ScrollDown
  1114.   ELSE
  1115.     EXIT FOR
  1116.   END IF
  1117. NEXT PageLenght%
  1118.  
  1119. RETURN
  1120. '----------------------------------------------------------------------------
  1121. PageDown:
  1122.  
  1123. Oldptr% = TempPointer%
  1124.  
  1125. IF ISFALSE LastLine% THEN
  1126.   FOR PageLenght% = Top% TO (Bottom% - 1)
  1127.     GOSUB ScrollUp
  1128.     TempPointer% = Pointer%
  1129.     IF Pointer% = 0 THEN
  1130.       Pointer% = Oldptr%
  1131.       EXIT FOR
  1132.     END IF
  1133.   NEXT PageLenght%
  1134. END IF
  1135.  
  1136. RETURN
  1137. '----------------------------------------------------------------------------
  1138. ScrollUp:
  1139.  
  1140. IF TempPointer% < LEN(Text$) THEN
  1141.   Pointer% = INSTR(Pointer%, Text$, CHR$(13)) + 2
  1142. END IF
  1143.  
  1144. RETURN
  1145. '----------------------------------------------------------------------------
  1146. ScrollDown:
  1147.  
  1148. IF Pointer% > 1 THEN
  1149.   DECR Pointer%,2
  1150.   DO
  1151.     DECR Pointer%
  1152.   LOOP UNTIL MID$(Text$, Pointer%, 1) = CHR$(13) OR Pointer% = 1
  1153.   IF Pointer% > 1 THEN INCR Pointer%,2
  1154. END IF
  1155.  
  1156. RETURN
  1157. '----------------------------------------------------------------------------
  1158. RestoreBlockBegin:
  1159.  
  1160. IF BlockBeginPointer% THEN
  1161.   Pointer% = BlockBeginPointer%: Offset% = BlockBeginOffset%
  1162.   CursorRow% = BlockBeginCursorRow%: CursorCol% = BlockBeginCursorCol%
  1163. ELSE
  1164.   Message$(1) = "Beginning of Block not Marked"
  1165.   SOUND 50,5
  1166.   DIALOG Message$(),"",Mouse%,3,0,0,ErrorTxt%,ErrorAttr%,1,2
  1167. END IF
  1168.  
  1169. RETURN
  1170. '----------------------------------------------------------------------------
  1171. RestoreBlockEnd:
  1172.  
  1173. IF BlockEndPointer% THEN
  1174.   Pointer% = BlockEndPointer%: Offset% = BlockEndOffset%
  1175.   CursorRow% = BlockEndCursorRow%: CursorCol% = BlockEndCursorCol%
  1176. ELSE
  1177.   Message$(1) = "End of Block not Marked"
  1178.   SOUND 50,5
  1179.   DIALOG Message$(),"",Mouse%,3,0,0,ErrorTxt%,ErrorAttr%,1,2
  1180. END IF
  1181.  
  1182. RETURN
  1183. '----------------------------------------------------------------------------
  1184. MarkBlockBegin:
  1185.  
  1186. Character% = EditStartPointer% + Offset% + (CursorCol% - LeftSide%)
  1187. IF Character% <= EditEndPointer% THEN
  1188.   BlockStart% = EditStartPointer% + Offset% + (CursorCol% - LeftSide%)
  1189.   BlockBeginPointer% = Pointer%: BlockBeginOffset% = Offset%
  1190.   BlockBeginCursorRow% = CursorRow%: BlockBeginCursorCol% = CursorCol%
  1191.   IF BlockEnd% > BlockStart% THEN
  1192.     Change% = 0
  1193.     SOUND 2500,.5: SOUND 3000,.5: SOUND 3500,.5
  1194.     Block$ = MID$(Text$,BlockStart%,BlockEnd%-BlockStart%)
  1195.   END IF
  1196. ELSE
  1197.   Message$(1) = "Cursor is Past the End of the Line!"
  1198.   SOUND 50,5
  1199.   DIALOG Message$(),"",Mouse%,3,0,0,ErrorTxt%,ErrorAttr%,1,2
  1200. END IF
  1201.  
  1202. RETURN
  1203. '----------------------------------------------------------------------------
  1204. MarkBlockEnd:
  1205.  
  1206. Character% = EditStartPointer% + Offset% + (CursorCol% - LeftSide%)
  1207. IF Character% <= EditEndPointer% THEN
  1208.   BlockEnd% = EditStartPointer% + Offset% + (CursorCol% - LeftSide%)
  1209.   BlockEndPointer% = Pointer%: BlockEndOffset% = Offset%
  1210.   BlockEndCursorRow% = CursorRow%: BlockEndCursorCol% = CursorCol%
  1211.   IF BlockEnd% > BlockStart% THEN
  1212.     Change% = 0
  1213.     SOUND 2500,.5: SOUND 3000,.5: SOUND 3500,.5
  1214.     Block$ = MID$(Text$,BlockStart%,BlockEnd% - BlockStart%)
  1215.   END IF
  1216. ELSE
  1217.   Message$(1) = "Cursor is Past the End of the Line!"
  1218.   SOUND 50,5
  1219.   DIALOG Message$(),"",Mouse%,3,0,0,ErrorTxt%,ErrorAttr%,1,2
  1220. END IF
  1221.  
  1222. RETURN
  1223. '----------------------------------------------------------------------------
  1224. CopyBlock:
  1225.  
  1226. NoSave% = 1: Change% = 0
  1227.  
  1228. IF LEN(Block$) THEN
  1229.   OldBlock$ = ""
  1230.   Character% = EditStartPointer% + Offset% + (CursorCol% - LeftSide%)
  1231.   IF ((Offset% + CursorCol%) - LeftSide%) > EditLineLenght% THEN
  1232.     Text$ = LEFT$(Text$,EditEndPointer% - 1) + _
  1233.     SPACE$(((Offset% + CursorCol%) - LeftSide%) - EditLineLenght%) + _
  1234.     Block$ + MID$(Text$, EditEndPointer%)
  1235.   ELSE
  1236.     Text$ = LEFT$(Text$,Character% - 1) + Block$ + MID$(Text$, Character%)
  1237.   END IF
  1238.   BlockStart% = Character%: BlockEnd% = Character% + LEN(Block$)
  1239. END IF
  1240.  
  1241. RETURN
  1242. '----------------------------------------------------------------------------
  1243. MoveBlock:
  1244.  
  1245. NoSave% = 1
  1246.  
  1247. IF LEN(Block$) THEN
  1248.   IF Block$ = OldBlock$ THEN
  1249.     Message$(1) = "You Cannot Move A Deleted Block use Copy Instead"
  1250.     SOUND 50,5
  1251.     DIALOG Message$(),"",Mouse%,3,0,0,ErrorTxt%,ErrorAttr%,1,2
  1252.   ELSE
  1253.     IF Change% = 0 THEN
  1254.       BlockBeginPointer% = 0: BlockEndPointer% = 0
  1255.       Character% = EditStartPointer% + Offset% + (CursorCol% - LeftSide%)
  1256.       IF Character% > EditEndPointer% THEN Character% = EditEndPointer%
  1257.       IF Character% < BlockStart% THEN
  1258.         Text$ = LEFT$(Text$,BlockStart% - 1) + MID$(Text$,BlockEnd%)
  1259.         Text$ = LEFT$(Text$,Character% - 1) + Block$ + MID$(Text$,Character%)
  1260.         BlockStart% = Character%: BlockEnd% = Character% + LEN(Block$)
  1261.       ELSEIF Character% > BlockEnd% THEN
  1262.         Text$ = LEFT$(Text$,Character% - 1) + Block$ + MID$(Text$,Character%)
  1263.         Text$ = LEFT$(Text$,BlockStart% - 1) + MID$(Text$,BlockEnd%)
  1264.         BlockStart% = Character%: BlockEnd% = Character% + LEN(Block$)
  1265.       END IF
  1266.     ELSE
  1267.       Message$(1) = "Pointers are no longer Valid! Remark Block"
  1268.       SOUND 50,5
  1269.       DIALOG Message$(),"",Mouse%,3,0,0,ErrorTxt%,ErrorAttr%,1,2
  1270.     END IF
  1271.   END IF
  1272. END IF
  1273.  
  1274. RETURN
  1275. '----------------------------------------------------------------------------
  1276. DeleteWordRight:
  1277.  
  1278. NoSave% = 1
  1279.  
  1280. GOSUB CheckForChange
  1281.  
  1282. IF Character% < EditEndPointer% THEN
  1283.   Temp% = (INSTR(Character% + 1,Text$,ANY CHR$(32,10)) + 1) - Character%
  1284.   SaveLine$ =  MID$(Text$,Character%,temp%) + CHR$(255) + SaveLine$
  1285.   Text$ = LEFT$(Text$,Character% - 1) + MID$(Text$,Character% + Temp%)
  1286.   IF Text$ = "" THEN Text$ = CHR$(13) + CHR$(10)
  1287. END IF
  1288.  
  1289. RETURN
  1290. '----------------------------------------------------------------------------
  1291. RestoreLine:
  1292.  
  1293. NoSave% = 1
  1294.  
  1295. GOSUB CheckForChange
  1296.  
  1297. IF LEN(SaveLine$) THEN
  1298.   Temp$ = EXTRACT$(SaveLine$,CHR$(255))
  1299.   IF LEN(Temp$) THEN
  1300.     SaveLine$ = MID$(SaveLine$,INSTR(SaveLine$,CHR$(255)) + 1)
  1301.     IF ((Offset% + CursorCol%) - LeftSide%) > EditLineLenght% THEN
  1302.       Text$ = LEFT$(Text$,EditEndPointer% - 1) + _
  1303.       SPACE$(((Offset% + CursorCol%) - LeftSide%) - EditLineLenght%) + _
  1304.       Temp$ + MID$(Text$, EditEndPointer%)
  1305.     ELSE
  1306.       Text$ = LEFT$(Text$,Character% - 1) + Temp$ + MID$(Text$, Character%)
  1307.     END IF
  1308.   ELSE
  1309.     IF SaveLine$ = Temp$ + CHR$(255) THEN SaveLine$ = ""
  1310.   END IF
  1311. END IF
  1312.  
  1313. RETURN
  1314. '----------------------------------------------------------------------------
  1315. DeleteToEndOfLine:
  1316.  
  1317. NoSave% = 1
  1318.  
  1319. GOSUB CheckForChange
  1320.  
  1321. IF Character% < EditEndPointer% THEN
  1322.   i% = ((EditStartPointer% + Offset% + CursorCol%) - LeftSide%)
  1323.   SaveLine$ = MID$(Text$,i%,EditEndPointer% - i%) + CHR$(255) + SaveLine$
  1324.   Text$ = LEFT$(Text$,i% - 1) + MID$(Text$,EditEndPointer%)
  1325. END IF
  1326.  
  1327. RETURN
  1328. '----------------------------------------------------------------------------
  1329. DeleteLine:
  1330.  
  1331. NoSave% = 1
  1332.  
  1333. GOSUB CheckForChange
  1334.  
  1335. SaveLine$ = MID$(Text$,EditStartPointer%,EditEndPointer% - EditStartPointer%) + _
  1336. CHR$(13) + CHR$(10) + CHR$(255) + SaveLine$
  1337. Text$ = LEFT$(Text$,EditStartPointer% - 1) + MID$(Text$,EditEndPointer% + 2)
  1338. IF Text$ = "" THEN Text$ = CHR$(13) + CHR$(10)
  1339.  
  1340. RETURN
  1341. '----------------------------------------------------------------------------
  1342. CheckForChange:
  1343.  
  1344. Character% = EditStartPointer% + Offset% + (CursorCol% - LeftSide%)
  1345.  
  1346. IF BlockEnd% THEN
  1347.   IF Character% < BlockEnd% THEN Change% = 1
  1348. END IF
  1349.  
  1350. RETURN
  1351. '----------------------------------------------------------------------------
  1352. DeleteBlock:
  1353.  
  1354. NoSave% = 1
  1355.  
  1356. IF LEN(Block$) THEN
  1357.   IF Change% = 0 THEN
  1358.     BlockEndPointer% = 0
  1359.     IF Block$ = OldBlock$ THEN
  1360.       Message$(1) = "You have Deleted that Block Already !!!"
  1361.       SOUND 50,5
  1362.       DIALOG Message$(),"",Mouse%,3,0,0,ErrorTxt%,ErrorAttr%,1,2
  1363.     ELSE
  1364.       OldBlock$ = Block$
  1365.       Text$ = LEFT$(Text$,BlockStart% - 1) + MID$(Text$,BlockEnd%)
  1366.       IF Text$ = "" THEN Text$ = CHR$(13) + CHR$(10)
  1367.     END IF
  1368.   ELSE
  1369.     Message$(1) = "Pointers are no longer Valid! Remark Block"
  1370.     SOUND 50,5
  1371.     DIALOG Message$(),"",Mouse%,3,0,0,ErrorTxt%,ErrorAttr%,1,2
  1372.   END IF
  1373. END IF
  1374.  
  1375. RETURN
  1376. '----------------------------------------------------------------------------
  1377. FindText:
  1378.  
  1379. SearchPointer% = Pointer%
  1380. TextOne$ = SPACE$(45)
  1381. EditBox "Find what:",TextOne$,Allow$,Mouse%,176,6,79,14,112,1,1
  1382. TextOne$ = RTRIM$(TextOne$)
  1383.  
  1384. IF LEN(TextOne$) THEN GOSUB SearchAgain
  1385.  
  1386. RETURN
  1387. '----------------------------------------------------------------------------
  1388. SearchAndReplace:
  1389.  
  1390. SearchPointer% = Pointer%
  1391. TextOne$ = SPACE$(40)
  1392. TextTwo$ = SPACE$(40)
  1393. DoubleBox "Find what:","Replace with:",TextOne$,TextTwo$,Allow$,Mouse%,255,176,6,79,14,112,1,1
  1394. TextOne$ = RTRIM$(TextOne$)
  1395. TextTwo$ = RTRIM$(TextTwo$)
  1396.  
  1397. IF LEN(TextOne$) AND LEN(TextTwo$) THEN
  1398.   DO
  1399.     GOSUB SearchAgain
  1400.     IF TestPointer% THEN
  1401.       GOSUB PrintRoutine
  1402.       GOSUB FileInfo
  1403.       LOCATE 3,CursorCol%,0: COLOR 31,1: PRINT TextOne$;
  1404.       MayBe "Replace the Hilighted Text ? (Y or N or Esc)",Answer%,Mouse%,10,79,112%,1,1
  1405.       SELECT CASE Answer%
  1406.              CASE 0
  1407.                EXIT SELECT
  1408.              CASE 1
  1409.                NoSave% = 1
  1410.                GOSUB CheckForChange
  1411.                Text$ = LEFT$(Text$,TestPointer% - 1) + TextTwo$ + MID$(Text$,(TestPointer% + LEN(TextOne$)))
  1412.                GOSUB PrintRoutine
  1413.                DELAY .5
  1414.              CASE 2
  1415.                RETURN
  1416.       END SELECT
  1417.     END IF
  1418.   LOOP WHILE TestPointer%
  1419. ELSE
  1420.   Message$(1) = "Both Lines must contain Text"
  1421.   IF LEN(TextOne$) OR LEN(TextTwo$) THEN SOUND 50,5: DIALOG Message$(),"",Mouse%,3,0,0,ErrorTxt%,ErrorAttr%,1,2
  1422. END IF
  1423.  
  1424. RETURN
  1425. '----------------------------------------------------------------------------
  1426. SearchAgain:
  1427.  
  1428. Position% = 0
  1429.  
  1430. IF LEN(TextOne$) THEN
  1431.   IF SearchPointer% THEN
  1432.     SearchPointer% = INSTR(SearchPointer%,Text$,TextOne$)
  1433.     IF ISFALSE SearchPointer% THEN
  1434.       Message$(1) = "Text Not Found or No More Matches"
  1435.       SOUND 50,5
  1436.       DIALOG Message$(),"",Mouse%,3,0,0,ErrorTxt%,ErrorAttr%,1,2
  1437.       TestPointer% = SearchPointer%
  1438.       RETURN
  1439.     END IF
  1440.   END IF
  1441. ELSE
  1442.   Message$(1) = "No Text to Search For"
  1443.   SOUND 50,5
  1444.   DIALOG Message$(),"",Mouse%,3,0,0,ErrorTxt%,ErrorAttr%,1,2
  1445.   RETURN
  1446. END IF
  1447.  
  1448. TestPointer% = SearchPointer%
  1449.  
  1450. IF SearchPointer% THEN
  1451.     DO
  1452.       IF SearchPointer% > 1 THEN DECR SearchPointer%: INCR Position%
  1453.     LOOP UNTIL MID$(Text$, SearchPointer%, 1) = CHR$(13) OR SearchPointer% = 1
  1454.     IF SearchPointer% > 1 THEN
  1455.       INCR SearchPointer%,2
  1456.     ELSE
  1457.       IF ISFALSE Add% THEN
  1458.         INCR Position%,2
  1459.       ELSE
  1460.         INCR SearchPointer%,2
  1461.       END IF
  1462.     END IF
  1463. END IF
  1464.  
  1465. IF SearchPointer% THEN
  1466.   Pointer% = SearchPointer%
  1467.   INCR SearchPointer%,(Position% + LEN(TextOne$))
  1468.   IF Position% + LEN(TextOne$) > 78 THEN
  1469.     Offset% = (Position% + LEN(TextOne$)) - 78
  1470.     CursorCol% = 78 - LEN(TextOne$)
  1471.   ELSE
  1472.     Offset% = 0
  1473.     CursorCol% = Position%
  1474.   END IF
  1475.   CursorRow% = Top%
  1476. END IF
  1477.  
  1478. RETURN
  1479. '----------------------------------------------------------------------------
  1480. MarkPosition:
  1481.  
  1482. MarkedPointer% = Pointer%: MarkedOffset% = Offset%
  1483. MarkedCursorRow% = CursorRow%: MarkedCursorCol% = CursorCol%
  1484.  
  1485. RETURN
  1486. '----------------------------------------------------------------------------
  1487. RestorePosition:
  1488.  
  1489. IF MarkedPointer% THEN
  1490.   Pointer% = MarkedPointer%: Offset% = MarkedOffset%
  1491.   CursorRow% = MarkedCursorRow%: CursorCol% = MarkedCursorCol%
  1492. ELSE
  1493.   Message$(1) = "Previous Position Not Marked"
  1494.   SOUND 50,5
  1495.   DIALOG Message$(),"",Mouse%,3,0,0,ErrorTxt%,ErrorAttr%,1,2
  1496. END IF
  1497.  
  1498. RETURN
  1499. '----------------------------------------------------------------------------
  1500. DosShell:
  1501.  
  1502. MEMPACK
  1503. SaveScreen Dos$,1,1,25,80,0
  1504. COLOR 7,0: CLS: LOCATE 1,1,0
  1505. PRINT "Type EXIT to Return to DNAWrite";
  1506. SHELL
  1507. RestoreScreen Dos$,1,1
  1508.  
  1509. RETURN
  1510. '----------------------------------------------------------------------------
  1511. FileInfo:
  1512.  
  1513. FileSize% = LEN(Text$)
  1514. ColNumber% = ((Offset% + CursorCol%) - LeftSide%)
  1515. LineNumber% = 0
  1516.  
  1517. FOR i% = 1 TO EditEndPointer%
  1518.   j% = INSTR(i%,Text$,CHR$(13))
  1519.   IF j% THEN INCR LineNumber%: i% = j%
  1520. NEXT i%
  1521.  
  1522. COLOR 7,1
  1523. LOCATE 2,2,0: PRINT RIGHT$(STRING$(77,196) + "┤ " + CurrentName$ + " ├",77);
  1524. LOCATE 24,9,0: PRINT LEFT$(STR$(LineNumber%) + "   ",4);
  1525. LOCATE 24,18,0: PRINT LEFT$(STR$(ColNumber% + 1) + "   ",4);
  1526. IF FileSize% > 31999 THEN COLOR 31,1
  1527. LOCATE 24,42,0: PRINT LEFT$(STR$(FileSize%) + "     ",6);
  1528.  
  1529. RETURN
  1530. '----------------------------------------------------------------------------
  1531. CtrlKHelp:
  1532.  
  1533. SaveScreen CtrlK$,6,50,21,76,1
  1534. Popwind "Control - K",6,50,21,76,112,1,1
  1535. COLOR 0,7
  1536. LOCATE 7,52,0: PRINT "B  mark block begin";
  1537. LOCATE 8,52,0: PRINT "K  mark block end";
  1538. LOCATE 9,52,0: PRINT "T  mark single word";
  1539. LOCATE 10,52,0: PRINT "C  copy block";
  1540. LOCATE 11,52,0: PRINT "V  move block";
  1541. LOCATE 12,52,0: PRINT "Y  delete block";
  1542. LOCATE 13,52,0: PRINT "R  read block from file";
  1543. LOCATE 14,52,0: PRINT "W  save marked block";
  1544. LOCATE 15,52,0: PRINT "H  view clipboard";
  1545. LOCATE 16,52,0: PRINT "P  print block";
  1546. LOCATE 17,52,0: PRINT "D  save and exit";
  1547. LOCATE 18,52,0: PRINT "S  save";
  1548. LOCATE 19,52,0: PRINT "Q  quit without saving";
  1549. LOCATE 20,52,0: PRINT "N  set place marker";
  1550.  
  1551. RETURN
  1552. '----------------------------------------------------------------------------
  1553. CtrlQHelp:
  1554.  
  1555. SaveScreen CtrlQ$,6,50,21,76,1
  1556. Popwind "Control - Q",6,50,21,76,112,1,1
  1557.  
  1558. COLOR 0,7
  1559. LOCATE 7,52,0: PRINT "S  beginning of line";
  1560. LOCATE 8,52,0: PRINT "D  end of line";
  1561. LOCATE 9,52,0: PRINT "E  top of window";
  1562. LOCATE 10,52,0: PRINT "X  bottom of window";
  1563. LOCATE 11,52,0: PRINT "R  top of file";
  1564. LOCATE 12,52,0: PRINT "C  end of file";
  1565. LOCATE 13,52,0: PRINT "B  beginning of block";
  1566. LOCATE 14,52,0: PRINT "K  end of block";
  1567. LOCATE 15,52,0: PRINT "P  last cursor position";
  1568. LOCATE 16,52,0: PRINT "W  restore last message";
  1569. LOCATE 17,52,0: PRINT "Y  delete to line end";
  1570. LOCATE 18,52,0: PRINT "L  restore line";
  1571. LOCATE 19,52,0: PRINT "F  search";
  1572. LOCATE 20,52,0: PRINT "A  search and replace";
  1573.  
  1574. RETURN
  1575. '----------------------------------------------------------------------------
  1576. PrintRoutine:
  1577.  
  1578. IF Mouse% THEN HideCursor
  1579.  
  1580.  TempPointer% = Pointer% : Row% = Top% : LastLine% = 0: FirstTime% = 1
  1581.  IF RIGHT$(Text$,2) <> CHR$(13) + CHR$(10) THEN Text$ = Text$ + CHR$(13) + CHR$(10)
  1582.  DO
  1583.   EndOfLine% = INSTR(MID$(Text$,TempPointer%),CHR$(13))
  1584.     IF EndOfLine% = 0 THEN
  1585.       EndOfLine% = LEN(Text$)
  1586.       IF LastLine% = 0 THEN
  1587.         LastLine% = Row% - 1
  1588.         DECR Row%
  1589.         EndOfLine% = LastEndOfLine%
  1590.         TempPointer% = LastPointer%
  1591.       END IF
  1592.       IF CursorRow% > LastLine% THEN  CursorRow% = LastLine%
  1593.     ELSE
  1594.       DECR EndOfLine%   ' DECR: do not show the CR
  1595.     END IF
  1596.   LastPointer% = TempPointer%: LastEndOfLine% = EndOfLine%
  1597.   CurrentLine$ = MID$(Text$, TempPointer%,EndOfLine%)
  1598.   IF CurrentLine$ = CHR$(10) THEN CurrentLine$ = ""
  1599.   IF Row% = CursorRow% THEN
  1600.     EditLineLenght% = LEN(CurrentLine$)
  1601.     EditStartPointer% = TempPointer%
  1602.     EditEndPointer% = TempPointer% + EndOfLine%
  1603.   END IF
  1604.   QPRINT Row%, LeftSide%, MID$(CurrentLine$ + SPACE$(TextWidth% + Offset%), 1 + Offset% , TextWidth%), TextAttr%
  1605.   TempPointer% = INSTR(TempPointer%,Text$, CHR$(13)) + 2  ' +2 for CRLF
  1606.   IF Pointer% = 1 AND FirstTime% THEN
  1607.     FirstTime% = 0
  1608.     IF TempPointer% > 5 THEN Add% = 0 ELSE Add% = 1
  1609.   END IF
  1610.   IF TempPointer% = 2 THEN TempPointer% = LEN(Text$)
  1611.   INCR Row%
  1612.   IF Row% > Bottom% THEN EXIT LOOP
  1613.  LOOP
  1614.  
  1615. RETURN
  1616. '----------------------------------------------------------------------------
  1617. Save:
  1618.  
  1619. IF LEN(CurrentName$) THEN
  1620.   FileNumber% = FREEFILE
  1621.   OPEN CurrentName$ FOR OUTPUT AS #FileNumber%
  1622.   PRINT #FileNumber%,Text$;
  1623.   CLOSE #FileNumber%
  1624.   NoSave% = 0
  1625. END IF
  1626.  
  1627. RETURN
  1628. '----------------------------------------------------------------------------
  1629. SaveAs:
  1630.  
  1631. Kurrent$ = CurrentName$
  1632.  
  1633. FOR i% = 1 TO LEN(Kurrent$)      'get the path and file name
  1634.   Test$ = RIGHT$(Kurrent$,i%)
  1635.   IF LEFT$(Test$,1) = CHR$(92) THEN
  1636.     FindPath$ = LEFT$(Kurrent$,LEN(Kurrent$) - (i% - 1))
  1637.     EXIT FOR
  1638.   END IF
  1639. NEXT i%
  1640.  
  1641. DefaultName$ = LTRIM$(Kurrent$,FindPath$)
  1642.  
  1643. WriteToBox ReturnedFile$,DefaultName$,Mouse%,112,14,79,1,1
  1644.  
  1645. IF LEN(ReturnedFile$) THEN CurrentName$ = ReturnedFile$: GOSUB Save
  1646.  
  1647. RETURN
  1648. '----------------------------------------------------------------------------
  1649. QuitSave:
  1650.  
  1651. GOSUB SaveAll
  1652. GOTO WayOut
  1653.  
  1654. RETURN
  1655. '----------------------------------------------------------------------------
  1656. PrinterSetup:
  1657.  
  1658. PrnCfg$ = Home$ + "PRINTER.CFG"
  1659. Count% = 0
  1660.  
  1661. Test$ = DIR$(PrnCfg$)
  1662.  
  1663. IF LEN(Test$) THEN
  1664.   OPEN PrnCfg$ FOR INPUT AS #1
  1665.   DO
  1666.     INCR Count%
  1667.     LINE INPUT #1, Prnter$(Count%)
  1668.     LINE INPUT #1, Action$(Count%)
  1669.   LOOP WHILE NOT EOF(1)
  1670.   CLOSE #1
  1671. ELSE
  1672.   RETURN
  1673. END IF
  1674.  
  1675. SCROLLBOX Prnter$(),Instruction$,"Printer",Mouse%,10,Tag%,1,0,0,14,112,0,0,1,1
  1676.  
  1677. IF LEN(Instruction$) THEN
  1678.   TagCount% = 0
  1679.   IF Tag% THEN
  1680.     Temp$ = LTRIM$(Instruction$,CHR$(Tag%))
  1681.   ELSE
  1682.     Temp$ = LTRIM$(Instruction$)
  1683.   END IF
  1684.   DO
  1685.     INCR TagCount%
  1686.     b% = INSTR(Temp$,ANY CHR$(Tag%))
  1687.     IF b% = 0 THEN
  1688.       Compare$(TagCount%) = Temp$
  1689.     ELSE
  1690.       Compare$(TagCount%) = LEFT$(Temp$,b% - 1)
  1691.     END IF
  1692.     Temp$ = LTRIM$(Temp$,Compare$(TagCount%))
  1693.     Temp$ = LTRIM$(Temp$,CHR$(Tag%))
  1694.   LOOP UNTIL Compare$(TagCount%) = ""
  1695.   DECR TagCount%
  1696.   FOR i% = 1 TO TagCount%
  1697.     j% = 0
  1698.     DO
  1699.       INCR j%
  1700.       IF Prnter$(j%) = Compare$(i%) THEN
  1701.         IF Immbed% THEN
  1702.           FOR k% = 1 TO LEN(Action$(j%))
  1703.             a$ = LEFT$(Action$(j%),k%)
  1704.             b$ = RIGHT$(a$,1)
  1705.             Ky$ = b$
  1706.             GOSUB AddText
  1707.             GOSUB PrintRoutine
  1708.           NEXT k%
  1709.           EXIT LOOP
  1710.         ELSE
  1711.           LPRINT Action$(j%);
  1712.           EXIT LOOP
  1713.         END IF
  1714.       END IF
  1715.     LOOP UNTIL j% = Count%
  1716.   NEXT i%
  1717.   FOR i% = 1 to TagCount%
  1718.     Compare$(i%) = ""
  1719.   NEXT i%
  1720. END IF
  1721.  
  1722. RETURN
  1723. '----------------------------------------------------------------------------
  1724. PrintAll:
  1725.  
  1726. WIDTH "LPT1:",255
  1727. LPRINT Text$
  1728.  
  1729. SOUND 5000,.5:SOUND 1000,.5
  1730.  
  1731. RETURN
  1732. '----------------------------------------------------------------------------
  1733. WriteBlockToDisk:
  1734.  
  1735. WriteToBox ReturnedFile$,"NONAME.BLK",Mouse%,112,14,79,1,1
  1736. BlockName$ = ReturnedFile$
  1737.  
  1738. IF LEN(BlockName$) THEN
  1739.   FileNumber% = FREEFILE
  1740.   OPEN BlockName$ FOR OUTPUT AS #FileNumber%
  1741.   PRINT #FileNumber%,Block$;
  1742.   CLOSE #FileNumber%
  1743. END IF
  1744.  
  1745. RETURN
  1746. '----------------------------------------------------------------------------
  1747. SaveAll:
  1748.  
  1749. IF NoSave% THEN
  1750.   IF CurrentName$ = "NONAME.TXT" THEN
  1751.     WriteToBox ReturnedFile$,"NONAME.TXT",Mouse%,112,14,79,1,1
  1752.     IF LEN(ReturnedFile$) THEN
  1753.       CurrentName$ = ReturnedFile$: GOSUB Save
  1754.     END IF
  1755.     RETURN
  1756.   ELSE
  1757.     IF YesNo%("Save " + CurrentName$ + " (Y or N)",1,10,79,112,1,1) THEN
  1758.       GOSUB Save
  1759.     END IF
  1760.     RETURN
  1761.   END IF
  1762. ELSE
  1763.   RETURN
  1764. END IF
  1765.  
  1766. RETURN
  1767. '----------------------------------------------------------------------------
  1768. ClearAll:
  1769.  
  1770. GOSUB SaveAll
  1771.  
  1772. DefaultFile:
  1773.  
  1774. CurrentName$ = "NONAME.TXT"
  1775. Text$ = CHR$(13,10)
  1776. Pointer% = 1: Offset% = 0: NoSave% = 0
  1777. CursorRow% = Top%: CursorCol% = LeftSide%
  1778. MarkedPointer% = 0: SearchPointer% = 1
  1779. BlockBeginPointer% = 0: BlockEndPointer% = 0
  1780. BlockStart% = 0: BlockEnd% = 0
  1781.  
  1782. RETURN
  1783. '----------------------------------------------------------------------------
  1784. LoadNew:
  1785.  
  1786. IF NoSave% THEN GOSUB SaveAll
  1787.  
  1788. InsertFile:
  1789.  
  1790. DirectoryBox FileName$,Mouse%,112,14,79,1,1
  1791.  
  1792. LoadFile:
  1793.  
  1794. IF LEN(FileName$) THEN
  1795.  FileNumber% = FREEFILE
  1796.  OPEN FileName$ FOR BINARY AS FileNumber%
  1797.  IF LOF(FileNumber%) > 32000 THEN
  1798.    ERROR 188
  1799.    CLOSE #FileNumber%
  1800.    RETURN
  1801.  ELSE
  1802.    IF InFile% = 1 THEN
  1803.      GET$ FileNumber%, LOF(FileNumber%),Block$
  1804.      InFile% = 0
  1805.      SaveScreen Msg$,12,31,14,49,1
  1806.      Popwind "",12,31,14,49,112,1,1
  1807.      COLOR 0,7: LOCATE 13,33,0: PRINT "Expanding Tabs";
  1808.      ExpandTabs Block$
  1809.      RestoreScreen Msg$,12,31
  1810.    ELSE
  1811.      GET$ FileNumber%, LOF(FileNumber%), Text$
  1812.      SaveScreen Msg$,12,31,14,49,1
  1813.      Popwind "",12,31,14,49,112,1,1
  1814.      COLOR 0,7: LOCATE 13,33,0: PRINT "Expanding Tabs";
  1815.      ExpandTabs Text$
  1816.      RestoreScreen Msg$,12,31
  1817.      CurrentName$ = FileName$
  1818.      IF Text$ = "" THEN Text$ = " " + CHR$(13) + CHR$(10)
  1819.      Offset% = 0: Pointer% = 1: NoSave% = 0
  1820.      CursorRow% = Top%: CursorCol% = LeftSide%
  1821.      MarkedPointer% = 0: SearchPointer% = 1
  1822.      BlockBeginPointer% = 0: BlockEndPointer% = 0
  1823.      BlockStart% = 0: BlockEnd% = 0
  1824.    END IF
  1825.    CLOSE #FileNumber%
  1826.  END IF
  1827. END IF
  1828.  
  1829. RETURN
  1830. '----------------------------------------------------------------------------
  1831. ViewClipboard:
  1832.  
  1833. CbOffset% = Offset%: CbPointer% = Pointer%: CbCursorRow% = CursorRow%
  1834. CbCursorCol% = CursorCol%: CbText$ = Text$
  1835.  
  1836. Pointer% = 1: CursorRow% = Top%: CusorCol% = LeftSide%
  1837. Offset% = 0: Text$ = Block$: TextAttr% = 112
  1838.  
  1839. IF Mouse% THEN HideCursor
  1840. ClipKey$ = "Viewing Keys │ Home End PageUp PageDown ArrowKeys │ Esc = Exit"
  1841. SaveScreen Clip$,2,1,24,80,0
  1842. Popwind ClipKey$,2,1,24,80,15,0,1
  1843.  
  1844. DO
  1845.  
  1846. GOSUB PrintRoutine
  1847.  
  1848. WHILE NOT INSTAT:WEND
  1849. Ky$ = INKEY$
  1850.  
  1851. IF LEN(Ky$) = 1 THEN
  1852.   Chose% = ASC(Ky$)
  1853. ELSE
  1854.   Chose% = -ASC(RIGHT$(Ky$,1))
  1855. END IF
  1856.  
  1857.   SELECT CASE Chose%
  1858.  
  1859.        CASE -80 'down arrow
  1860.          GOSUB ScrollUp
  1861.        CASE -72 ' up arrow
  1862.          GOSUB ScrollDown
  1863.        CASE -71 ' home
  1864.          GOSUB StartOfFile
  1865.        CASE -77 ' right arrow
  1866.         INCR Offset%
  1867.        CASE -75 ' left arrow
  1868.         IF Offset% THEN DECR Offset%
  1869.        CASE -81 ' page down
  1870.          GOSUB PageDown
  1871.        CASE -73 ' page up
  1872.          GOSUB PageUp
  1873.        CASE -79  'EndKey
  1874.          GOSUB EndOfFile
  1875.        CASE 27
  1876.          EXIT LOOP
  1877.        CASE ELSE
  1878.  
  1879.   END SELECT
  1880.  
  1881. LOOP
  1882.  
  1883. Offset% = CbOffset%: Pointer% = CbPointer%: CursorRow% = CbCursorRow%
  1884. CursorCol% = CbCursorCol%: Text$ = CbText$:
  1885. TextAttr% = 30
  1886. RestoreScreen Clip$,2,1
  1887.  
  1888. RETURN
  1889. '----------------------------------------------------------------------------
  1890. WriteError:
  1891.  
  1892. SELECT CASE ERR
  1893.  
  1894.   CASE 5
  1895.     Message$(1) = "   ILLEGAL FUNCTION CALL   "
  1896.   CASE 6
  1897.     Message$(1) = "   OVERFLOW   "
  1898.   CASE 7
  1899.     Message$(1) = "   OUT OF MEMORY   "
  1900.   CASE 9
  1901.     Message$(1) = "   SEGMENT OR STACK EXPIRED   "
  1902.   CASE 11
  1903.     Message$(1) = "   DIVIDE BY 0   "
  1904.   CASE 14
  1905.     Message$(1) = "   OUT OF VARIABLE SPACE   "
  1906.   CASE 15
  1907.     Message$(1) = "   FILE EXCEEDS 32K   "
  1908.   CASE 24
  1909.     Message$(1) = "   DEVICE TIMEOUT   "
  1910.   CASE 25
  1911.     Message$(1) = "   DEVICE FAULT   "
  1912.   CASE 27
  1913.     Message$(1) = "   NO PAPER   "
  1914.   CASE 52
  1915.     Message$(1) = "   IMPROPER FILE LOGIC   "
  1916.   CASE 53
  1917.     Message$(1) = "   FILE NOT ACCESSABLE   "
  1918.   CASE 54
  1919.     Message$(1) = "   BAD FILE MODE   "
  1920.   CASE 55
  1921.     Message$(1) = "   FILE IS OPEN   "
  1922.   CASE 57
  1923.     Message$(1) = "   DEVICE I/O   "
  1924.   CASE 58
  1925.     Message$(1) = "   FILE EXISTS   "
  1926.   CASE 61
  1927.     Message$(1) = "   DISK IS FULL   "
  1928.   CASE 62
  1929.     Message$(1) = "   UNEXPECTED END OF FILE   "
  1930.   CASE 64
  1931.     Message$(1) = "   BAD FILE NAME   "
  1932.   CASE 67
  1933.     Message$(1) = "   TOO MANY FILES OPEN   "
  1934.   CASE 68
  1935.     Message$(1) = "   DEVICE UNNAVAILABLE   "
  1936.   CASE 70
  1937.     Message$(1) = "   FILE LOCK   "
  1938.   CASE 71
  1939.     Message$(1) = "   DISK IS NOT READY   "
  1940.   CASE 72
  1941.     Message$(1) = "   DISK MEDIA ERROR   "
  1942.   CASE 73
  1943.     Message$(1) = "   ADVANCED FEATURE UNNAVAILABLE   "
  1944.   CASE 74
  1945.     Message$(1) = "   RENAME ACROSS DISKS   "
  1946.   CASE 75
  1947.     Message$(1) = "   BAD PATH/FILE   "
  1948.   CASE 76
  1949.     Message$(1) = "   PATH NOT FOUND   "
  1950.   CASE 188
  1951.     Message$(1) = "   FILE EXCEEDS 32K   "
  1952.   CASE ELSE
  1953.     Message$(1) = "   ERROR" + STR$(ERR) + " AT PGM-CTR" + STR$(ERADR) + "   "
  1954. END SELECT
  1955.  
  1956. SOUND 50,5
  1957. DIALOG Message$(),"",Mouse%,3,0,0,ErrorTxt%,ErrorAttr%,1,2
  1958.  
  1959. RESUME NEXT
  1960. '----------------------------------------------------------------------------
  1961. SUB QPrint(BYVAL Row%,BYVAL Col%,BYVAL St$, BYVAL Attr%)PUBLIC
  1962. ! push            si              ; Save em
  1963. ! push            di              ;
  1964. ! push            ds              ;
  1965. ! mov             ax,St$          ; get the handle
  1966. ! push            ax              ; push it
  1967. ! call            getstrloc       ; Get String info
  1968. ! mov             ds,dx           ; Set the string seg
  1969. ! mov             si,ax           ; set string ptr
  1970. ! cmp             cx,0            ; Quit if string = 0
  1971. ! je              Done            ;
  1972. ! xor             ax,ax           ;
  1973. ! mov             ax,Row%         ; get the row
  1974. ! dec             al              ; convert row to zero base
  1975. ! mov             bl,80           ; get the number of cols
  1976. ! mul             bl              ; multiply # of cols * rows
  1977. ! add             ax,Col%         ; add the column
  1978. ! dec             al              ; convert column to zero base
  1979. ! mov             di,ax           ; offset within video page
  1980. ! shl             di,1            ; account for color/attribute
  1981. ! mov             ax,&HB800       ; default to mono card segment
  1982. Display:
  1983. ! mov             es,ax           ; point ES to video
  1984. ! mov             ax,Attr%        ; color/attribute
  1985. ! mov          ah,al
  1986. Printit:
  1987. ! lodsb                           ; get a char into al
  1988. ! stosw                           ; write char and attr to screen
  1989. ! loop            Printit         ; go for entire string
  1990. Done:                             ' (len\counter already in cx)
  1991. ! pop             ds              ; pop em
  1992. ! pop             di              ;
  1993. ! pop             si              ;
  1994. END SUB